package com.scs.application.modules.base.excel.handler;

import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.afterturn.easypoi.excel.imports.ExcelImportService;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStream;

/**
 * @ Author     ：wyt
 * @ Date       ：Created in 下午 10:47 2023-10-08
 * @ Description：
 */
@Slf4j
public class ExcelImportUtilCustom {
    public static <T> ExcelImportResult<T> importExcelMore(InputStream inputstream, Class<?> pojoClass, ImportParams params) throws Exception {
        ExcelImportResult excelImportResult = (new ExcelImportService()).importExcelByIs(inputstream, pojoClass, params, true);
        if (excelImportResult.getFailList() != null || !excelImportResult.getFailList().isEmpty()) {
            log.error("importExcelMore.失败列表如下", JSON.toJSONString(excelImportResult.getFailList()));
            log.error( JSON.toJSONString(excelImportResult.getFailList()));
        }
        return excelImportResult;
    }
}
